package com.lang.response;

import lombok.Data;
import lombok.experimental.Accessors;

/**
 * creat by SimonLang
 * 2022/12/28 14:01
 */

@Data
@Accessors(chain = true)
public class PlatformResult<T> {

    /**
     * 状态码
     */
    private Integer code;

    /**
     * 提示信息
     */
    private String message;

    /**
     * 返回数据
     */
    private T data;


    public PlatformResult(Integer code, String message){
        this.code = code;
        this.message = message;
    }

    public PlatformResult(Integer code, String message, T data){
        this.code = code;
        this.message = message;
        this.data = data;
    }

    /**
     * 成功
     */

    public static <T>PlatformResult<T> SUCCESS(){
        return new PlatformResult<T>(ReturnResultEnum.SUCCESS.getCode(),ReturnResultEnum.SUCCESS.getMessage());
    }

    public static <T>PlatformResult<T> SUCCESS(T data){
        return new PlatformResult<>(ReturnResultEnum.SUCCESS.getCode(),ReturnResultEnum.SUCCESS.getMessage(),data);
    }

    /**
     *失败
     */
    public static PlatformResult FAIL(Integer code, String msg){
        return new PlatformResult<>(code,msg);
    }

    public static PlatformResult FAIL(String message){
        return new PlatformResult(ReturnResultEnum.FAIL.getCode(), message);
    }



}

